/**
 *  *2010-3-27 下午05:27:02  add 
 */
package com.base.myproject.client.ui;

import java.util.HashMap;

import com.base.myproject.client.system.BaseResource;
import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.ui.Image;

/**
 * @author Administrator
 *2010-3-27
 * javazgw@gmail.com
 */
public class HoursButton extends Image implements MouseDownHandler{
	int value=0;
	int orivalue=0;
	HashMap<String,String> hm = new HashMap<String,String>();
	boolean b;
	public HoursButton()
	{
		//super(BaseResource.INSTANCE.save2_16());
		//屏蔽事件
		//this.addMouseDownHandler(this);
		//add("2","2");
//		this.setSize("48px", "16px");
	
		this.setStylePrimaryName("HoursButton");
		this.setStyleName("HoursButton");
		paid();
	}

	

	@Override
	public void onMouseDown(MouseDownEvent event) {
		
		b=!b;
		if(b)
		{
			add("1","2");
		}
		else
		{
			remove("1");
		}
		
//		if((b&1)==1)
//		{
//			b=2;
//			this.setResource(BaseResource.INSTANCE.save2_16());
//		}
//		else if((b&2)==2)
//		{
//			b=4;
//			this.setResource(BaseResource.INSTANCE.auction_hammer());	
//		}
//		
//		else if((b&4)==4)
//		{
//			b=1;
//			this.setResource(BaseResource.INSTANCE.print_16());	
//		}
	}
	





	public void paid()
	{
	//System.out.println("BaseResource.INSTANCE.blue1_1().getURL()="+BaseResource.INSTANCE.blue1_1().getURL());
		if(hm.size()==0)
		{
		
			//this.setResource(BaseResource.INSTANCE.save2_16().getURL());
			//this.setUrl(BaseResource.INSTANCE.clear().getURL());
			this.setUrl("images/wite1_1.png");
			
		}
		else if(hm.size()==1)
		{
//			this.setResource(BaseResource.INSTANCE.auction_hammer());	
//			this.setUrl(BaseResource.INSTANCE.blue1_1().getURL());
			this.setUrl("images/blue1_1.jpg");
		}
		else if(hm.size()==2)
		{
//			this.setResource(BaseResource.INSTANCE.print_16());
//			this.setUrl(BaseResource.INSTANCE.red1_1().getURL());
			this.setUrl("images/red1_1.jpg");
		}
	}
	
	public void add(String key,String value)
	{
		hm.put(key, value);
		paid();
	}
	public void remove(String key)
	{
		hm.remove(key);
		paid();
	}

}
